class Menu {
    constructor(root) {
        this.root = root;
        this.$menu = $(`
            <div class="my_game_menu">
                <div class="my_game_menu_filed">
                    <div class="my_game_menu_filed_item my_game_menu_filed_single">
                        单人模式
                    </div>
                    
                    <div class="my_game_menu_filed_item my_game_menu_filed_multi">
                        多人模式
                    </div>
                    
                    <div class="my_game_menu_filed_item my_game_menu_filed_settings">
                        退出
                    </div>
                </div>
            </div>`
        );

        this.$single_mod = this.$menu.find(".my_game_menu_filed_single")
        this.$multi_mod = this.$menu.find(".my_game_menu_filed_multi")
        this.$settings = this.$menu.find(".my_game_menu_filed_settings")

        this.root.$my_game.append(this.$menu);
        this.start();
    }

    start() {
        this.add_listening_events();
    }

    add_listening_events() {
        let outer = this;
        this.$single_mod.click(function () {
            outer.hide();
            outer.root.playground.show();
        });

        this.$multi_mod.click(function () {
            alert("还在施工中...");
        });

        this.$settings.click(function () {
            outer.root.settings.logout_on_remote()
        });
    }

    show(){ // 显示menu界面
        this.$menu.show();
    }

    hide(){ // 关闭menu界面
        this.$menu.hide();
    }
}